package com.smart.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smart.model.domain.ProjectChangeReviewDO;
import com.smart.model.request.ProjectChangeReviewRequest;
import com.smart.model.vo.ProjectChangeReviewVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @author zhanghong
 */
@Repository
public interface ProjectChangeReviewMapper extends BaseMapper<ProjectChangeReviewDO> {
    ProjectChangeReviewDO selectDOById(Long id);
    List<ProjectChangeReviewDO> selectDOList(ProjectChangeReviewDO projectChangeReview);
    int insertDO(ProjectChangeReviewDO projectChangeReview);
    int batchInsertDO(List<ProjectChangeReviewDO> projectChangeReviewDOList);
    int updateDO(ProjectChangeReviewDO projectChangeReview);
    int deleteDOById(Long id);
    int deleteDOByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from project_change_review",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") ProjectChangeReviewRequest param);
    @Select({"<script>",
            "   select * from project_change_review",
            "   <where>",
            "       deleted=0",
            "       <if test=\"1==0\">and id=#{param.id}</if>",
            "   </where>",
            "   order by create_time desc limit #{limit} offset #{offset}",
            "</script>"})
    List<ProjectChangeReviewDO> pageQuery(@Param("param") ProjectChangeReviewRequest param, @Param("limit") int limit, @Param("offset") long offset);

    List<ProjectChangeReviewDO> selectByProjectId(@Param("id") long id);

    int deleteByProjectId(Long id);

    List<ProjectChangeReviewDO> selectDOByIProjectId(Long projectId);

    Integer selectByParames(@Param("projectId")Long projectId, @Param("startTime")Date startTime, @Param("endTime")Date endTime);
}
